﻿<style type="text/css">

.bhcsj{
	width: 350px;
	font-size: 12px;  
    background: #ffffff; 
    overflow: hidden;  
    text-overflow: ellipsis;  
    white-space: nowrap;
    
}
</style>
<div class="row">
    <div class="col-xs-12 col-md-12 col-lg-12">
        <div class="widget">
            <div class="widget-header bg-blue">
            	<i class="widget-icon fa fa-arrow-left"></i>
                <span class="widget-caption">自定义菜单</span>
                <div class="widget-buttons">
                    <a href="#" data-toggle="maximize">
                        <i class="fa fa-expand"></i>
                    </a>
                    <a href="#" data-toggle="collapse">
                        <i class="fa fa-minus"></i>
                    </a>
                    <a href="#" data-toggle="dispose">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="widget-body" style="height: auto;">
            	
            	
            	<!--  -->
            	<div class="widget-main ">
                    <div class="tabbable">
                        <ul class="nav nav-tabs tabs-flat" id="myTab11">
                            <li class="active">
                                <a data-toggle="tab" href="#client">
                                	客户
                                </a>
                            </li>
                            <li>
                                <a data-toggle="tab" href="#business">
                                	商户
                                </a>
                            </li>
                            <li>
                                <a data-toggle="tab" href="#auntie">
                                	社区管家
                                </a>
                            </li>
                        </ul>
                        <div class="tab-content tabs-flat">
                            <div id="client" class="tab-pane active">
                                <!-- 客户 -->
                               	<div class="table-toolbar">
									<a href="{:U('Admin/Wx/menu_set',array('wx_id'=>1))}" class="btn btn-primary" data-loader="bb-loader" data-loadername="设置自定义菜单">
										<i class="fa fa-plus"></i>新增菜单
									</a>
									<a id="upmenu" data-wxtype="1" class="btn btn-success upmenu" href="javascript:void(0);">
										<i class="fa fa-check"></i>更新菜单
									</a>
									<if condition="$session['admin']['user']['role']==1 || $session['admin']['user']['role']==2">
										<a id="delmenu" data-wxtype="1" class="btn btn-danger delmenu" href="javascript:void(0);">
											<i class="fa fa-times"></i> 删除菜单
										</a>
									</if>
									<!--<a id="getmenu" class="btn btn-success" href="javascript:void(0);">
										<i class="fa fa-check"></i>获取菜单
									</a>-->
								</div>
                               	
                               	<table class="table table-hover table-striped table-bordered">
				                    <thead class="bordered-blueberry">
				                        <tr role="row">
					                        	<th style="width: 25px;">id</th>
					                        	<th style="width: 120px;">名称</th>
					                        	<th style="width: 25px;">类型</th>
					                        	<th style="width: 260px;">网址</th>
					                        	<th style="width: 100px;">关键词</th>
					                        	<th style="width: 45px;">排序</th>
					                        	<th style="width: 135px;">操作</th>
				                        </tr>
				                    </thead>
				                    <tbody>
				                    	<volist name="wxnemu1" id="vo">
				                    		<tr>
				                    			<td>{$vo.id}</td>
				                    			<td>{$vo._name}</td>
				                    			<td>{$vo.type}</td>
				                    			<td><div class="bhcsj">{$vo.url}</div></td>
				                    			<td>{$vo.key}</td>
				                    			<td>{$vo.sort}</td>
				                    			<td style="text-align: center;">
				                        			<a href="{:U('Admin/Wx/menu_set',array('id'=>$vo['id'],'wx_id'=>1))}" data-loader="bb-loader" data-loadername="修改自定义菜单" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 修改</a>
				                        			<a href="#" id="del" data-id="{$vo.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
				                        		</td>
				                        		<volist name="vo['s']" id="vo2">
				                        			<tr>
					                        			<td>{$vo2.id}</td>
						                    			<td>{$vo2._name}</td>
						                    			<td>{$vo2.type}</td>
						                    			<td><div class="bhcsj">{$vo2.url}</div></td>
						                    			<td>{$vo2.key}</td>
						                    			<td>{$vo2.sort}</td>
						                    			<td style="text-align: center;">
						                        			<a href="{:U('Admin/Wx/menu_set',array('id'=>$vo2['id'],'wx_id'=>1))}" data-loader="bb-loader" data-loadername="修改自定义菜单" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 修改</a>
						                        			<a href="#" id="del" data-id="{$vo2.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
						                        		</td>
					                        		</tr>
				                        		</volist>
				                    		</tr>
				                    	</volist>
				                    </tbody>
				                </table>
                               	
                            	<!-- 客户 -->
                            </div>

                            <div id="business" class="tab-pane">
                                <!-- 商户 -->
                                <div class="table-toolbar">
									<a href="{:U('Admin/Wx/menu_set',array('wx_id'=>2))}" class="btn btn-primary" data-loader="bb-loader" data-loadername="设置自定义菜单">
										<i class="fa fa-plus"></i>新增菜单
									</a>
									<a id="upmenu" data-wxtype="2" class="btn btn-success upmenu" href="javascript:void(0);">
										<i class="fa fa-check"></i>更新菜单
									</a>
									<if condition="$session['admin']['user']['role']==1 || $session['admin']['user']['role']==2">
										<a id="delmenu" data-wxtype="2" class="btn btn-danger delmenu" href="javascript:void(0);">
											<i class="fa fa-times"></i> 删除菜单
										</a>
									</if>
									<!--<a id="getmenu" class="btn btn-success" href="javascript:void(0);">
										<i class="fa fa-check"></i>获取菜单
									</a>-->
								</div>
                                	
                                <table class="table table-hover table-striped table-bordered">
				                    <thead class="bordered-blueberry">
				                        <tr role="row">
					                        	<th style="width: 25px;">id</th>
					                        	<th style="width: 120px;">名称</th>
					                        	<th style="width: 25px;">类型</th>
					                        	<th style="width: 260px;">网址</th>
					                        	<th style="width: 100px;">关键词</th>
					                        	<th style="width: 45px;">排序</th>
					                        	<th style="width: 135px;">操作</th>
				                        </tr>
				                    </thead>
				                    <tbody>
				                    	<volist name="wxnemu2" id="vo">
				                    		<tr>
				                    			<td>{$vo.id}</td>
				                    			<td>{$vo._name}</td>
				                    			<td>{$vo.type}</td>
				                    			<td><div class="bhcsj">{$vo.url}</div></td>
				                    			<td>{$vo.key}</td>
				                    			<td>{$vo.sort}</td>
				                    			<td style="text-align: center;">
				                        			<a href="{:U('Admin/Wx/menu_set',array('id'=>$vo['id'],'wx_id'=>2))}" data-loader="bb-loader" data-loadername="修改自定义菜单" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 修改</a>
				                        			<a href="#" id="del" data-id="{$vo.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
				                        		</td>
				                        		<volist name="vo['s']" id="vo2">
				                        			<tr>
					                        			<td>{$vo2.id}</td>
						                    			<td>{$vo2._name}</td>
						                    			<td>{$vo2.type}</td>
						                    			<td><div class="bhcsj">{$vo2.url}</div></td>
						                    			<td>{$vo2.key}</td>
						                    			<td>{$vo2.sort}</td>
						                    			<td style="text-align: center;">
						                        			<a href="{:U('Admin/Wx/menu_set',array('id'=>$vo2['id'],'wx_id'=>2))}" data-loader="bb-loader" data-loadername="修改自定义菜单" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 修改</a>
						                        			<a href="#" id="del" data-id="{$vo2.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
						                        		</td>
					                        		</tr>
				                        		</volist>
				                    		</tr>
				                    	</volist>
				                    </tbody>
				                </table>	
                                	
                            	<!-- 商户 -->
                            </div>
                            
                            <div id="auntie" class="tab-pane">
                                <!-- 阿姨 -->
                                <div class="table-toolbar">
									<a href="{:U('Admin/Wx/menu_set',array('wx_id'=>3))}" class="btn btn-primary" data-loader="bb-loader" data-loadername="设置自定义菜单">
										<i class="fa fa-plus"></i>新增菜单
									</a>
									<a id="upmenu" data-wxtype="3" class="btn btn-success upmenu" href="javascript:void(0);">
										<i class="fa fa-check"></i>更新菜单
									</a>
									<if condition="$session['admin']['user']['role']==1 || $session['admin']['user']['role']==2">
										<a id="delmenu" data-wxtype="3" class="btn btn-danger delmenu" href="javascript:void(0);">
											<i class="fa fa-times"></i> 删除菜单
										</a>
									</if>
									<!--<a id="getmenu" class="btn btn-success" href="javascript:void(0);">
										<i class="fa fa-check"></i>获取菜单
									</a>-->
								</div>
                                	
                                <table class="table table-hover table-striped table-bordered">
				                    <thead class="bordered-blueberry">
				                        <tr role="row">
					                        	<th style="width: 25px;">id</th>
					                        	<th style="width: 120px;">名称</th>
					                        	<th style="width: 25px;">类型</th>
					                        	<th style="width: 260px;">网址</th>
					                        	<th style="width: 100px;">关键词</th>
					                        	<th style="width: 45px;">排序</th>
					                        	<th style="width: 135px;">操作</th>
				                        </tr>
				                    </thead>
				                    <tbody>
				                    	<volist name="wxnemu3" id="vo">
				                    		<tr>
				                    			<td>{$vo.id}</td>
				                    			<td>{$vo._name}</td>
				                    			<td>{$vo.type}</td>
				                    			<td><div class="bhcsj">{$vo.url}</div></td>
				                    			<td>{$vo.key}</td>
				                    			<td>{$vo.sort}</td>
				                    			<td style="text-align: center;">
				                        			<a href="{:U('Admin/Wx/menu_set',array('id'=>$vo['id'],'wx_id'=>3))}" data-loader="bb-loader" data-loadername="修改自定义菜单" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 修改</a>
				                        			<a href="#" id="del" data-id="{$vo.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
				                        		</td>
				                        		<volist name="vo['s']" id="vo2">
				                        			<tr>
					                        			<td>{$vo2.id}</td>
						                    			<td>{$vo2._name}</td>
						                    			<td>{$vo2.type}</td>
						                    			<td><div class="bhcsj">{$vo2.url}</div></td>
						                    			<td>{$vo2.key}</td>
						                    			<td>{$vo2.sort}</td>
						                    			<td style="text-align: center;">
						                        			<a href="{:U('Admin/Wx/menu_set',array('id'=>$vo2['id'],'wx_id'=>3))}" data-loader="bb-loader" data-loadername="修改自定义菜单" class="btn btn-info btn-xs edit"><i class="fa fa-edit"></i> 修改</a>
						                        			<a href="#" id="del" data-id="{$vo2.id}" class="btn btn-danger btn-xs delete"><i class="fa fa-trash-o"></i> 删除</a>
						                        		</td>
					                        		</tr>
				                        		</volist>
				                    		</tr>
				                    	</volist>
				                    </tbody>
				                </table>	
                            	<!-- 阿姨 -->
                            </div>
                        </div>
                    </div>
                </div>
            	<!--  -->

            </div>
        </div>
    </div>
</div>

<!--面包屑导航封装-->
<div id="tmpbread" style="display: none;">{$breadhtml}</div>
<script type="text/javascript">
	setBread($('#tmpbread').html());
</script>

<script type="text/javascript">
	//获取微信公众号中的微信菜单
	$('#getmenu').on('click',function(){
		var tourl="{:U('Admin/Wx/getmenu')}";
		var funok=function(){
			var callok=function(data){
				
				//成功删除后刷新
				$('#refresh-toggler').trigger('click');
				return false;
			};
			var callerr=function(){
				//拦截错误
				return false;
			};
			$.bb.ajax('post',tourl,'nodata',callok(),callerr);
		}						
		funok();
	});
	//更新微信自定义菜单
	$('.upmenu').on('click',function(){
		var tourl="{:U('Admin/Wx/menu_up')}";
		var wxtype=$(this).data('wxtype');
		var funok=function(){
			var callok=function(){
				//成功删除后刷新
				$('#refresh-toggler').trigger('click');
				return false;
			};
			var callerr=function(){
				//拦截错误
				return false;
			};
			$.bb.ajax('post',tourl,{'wxtype':wxtype},callok,callerr);
		}						
		$.bb.confirm("确认要更新微信菜单吗？",funok);
	});
	//删除微信自定义菜单
	$('.delmenu').on('click',function(){
		var tourl="{:U('Admin/Wx/menu_del')}";
		var wxtype=$(this).data('wxtype');
		var funok=function(){
			var callok=function(){
				//成功删除后刷新
				$('#refresh-toggler').trigger('click');
				return false;
			};
			var callerr=function(){
				//拦截错误
				return false;
			};
			$.bb.ajax('post',tourl,{'wxtype':wxtype},callok,callerr);
		}						
		$.bb.confirm("确认要删除微信中的菜单吗？(注：不要轻易删除微信上的菜单。)",funok);
	});
	//删除数据库中的菜单
	$('.delete').on('click',function(){
		var id=$(this).data('id');
		var tourl="{:U('Admin/Wx/delnemu')}";
		var funok=function(){
			var callok=function(){
				//成功删除后刷新
				$('#refresh-toggler').trigger('click');
				return false;
			};
			var callerr=function(){
				//拦截错误
				return false;
			};
			$.bb.ajax('post',tourl,{'id':id},callok,callerr);
		}						
		$.bb.confirm("确认要删除数据库的菜单吗？",funok);
	});
</script>